package com.ipartek.desarrollo.acciones;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ipartek.desarrollo.interfaces.IMatriculasDAO;
import com.ipartek.formacion.ddbb.DAOFactory;

public abstract class Accion {
	
	private static DAOFactory myDao = DAOFactory
			.getDAOFactory(DAOFactory.ODBC);

	public static IMatriculasDAO matriculasDAO = myDao.getInterfaceMatriculasDAO();
	
	public abstract String ejecutar(HttpServletRequest request,
			HttpServletResponse response);

	public static Accion getAccion(String tipo) {
		Accion accion = null;
		try {
			accion = (Accion) Class.forName(getPackage() + "." + tipo)
					.newInstance();
		} catch (InstantiationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return accion;
	}

	private static String getPackage() {
		return Accion.class.getPackage().getName();
	}
}